function gadget:GetInfo()
    return {
        name = "EMP ability",
        desc = "Stuns all (enemy?) units in the vicinity ",
        author = "Sean Heron",
        date = "January 2009",
        license = "GNU GPL v2, or later",
        layer = 3, -- watchout for which layer!
        enabled = true
    }
end


local CMD_EMP = 32288 -- stun command ID

local lastemp = {}

--############# stun settings #####################
local empData = {
				[1] = 	{
						stunRange = 100,
						stunDamage = 100,
						stunTime = 500,
						cooldown = 20 --in seconds
						},

				[2] = 	{
						stunRange = 200,
						stunDamage = 300,
						stunTime = 700,
						cooldown = 17 --in seconds
						},

				[3] = 	{
						stunRange = 300,
						stunDamage = 1000,
						stunTime = 1000,
						cooldown = 15 --in seconds
						}


				}
--################################################



if (gadgetHandler:IsSyncedCode()) then
--SYNCED

function gadget:CommandFallback(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions, cmdTag)

    --check if this is command was emmitted by the stun-button
    if (CMD_EMP ~= cmdID) then
        return false
    end

	--get emp level
	local empLevel
	if (unitDefID == UnitDefNames.queen.id) then -- added emp for queen as second ability
		empLevel = _G.AllEngines:GetEngineByUnitID(unitID):GetAbilityLvl(1)
	else -- this is for bishop, he has emp as first ability... we need to have a config file which makes this mapping "hero ability slot <=> ability"
		empLevel = _G.AllEngines:GetEngineByUnitID(unitID):GetAbilityLvl(0)
	end
	
	--by now we have 3 levels for emp... this problem has to be solved better!
	if (empLevel > 3) then
		empLevel = 3
	end

	--handle cooldown
	if (lastemp[unitID]~=nil)and(lastemp[unitID]+empData[empLevel].cooldown > Spring.GetGameSeconds()) then
		Spring.Echo("Emp not ready!")
		return true,true
	else
		lastemp[unitID] = Spring.GetGameSeconds()
	end

    -- get all units in cylinder
    x,y,z = Spring.GetUnitPosition(unitID)
    unitsToBeStunned = Spring.GetUnitsInCylinder(x,z, empData[empLevel].stunRange)

    --check for every unit if it's allied. If not, stun.
    for index,unit in pairs(unitsToBeStunned) do
        if (Spring.GetUnitTeam(unit)~=nil) then
            if (not Spring.AreTeamsAllied(Spring.GetUnitTeam(unit),teamID)) then
                Spring.AddUnitDamage(unit,empData[empLevel].stunDamage,empData[empLevel].stunTime,unitID)
            end
        end
    end

    return true,true

end


end